package org.summerframework.component.note;

import org.summerframework.component.enums.annotation.EnumKind;
import org.summerframework.core.base.dto.BaseEnum;
import lombok.Getter;

/**
 * @author 石超
 * @version v1.0.0
 */
@Getter
@EnumKind("NOTE_PLATFORM")
public enum PlatformEnum implements BaseEnum {
    ALIYUN(1, "阿里云"),
    TENCENT_CLOUD(2, "腾讯云");

    private Integer code;
    private String desc;

    PlatformEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static PlatformEnum getInstance(Integer code) {
        if (code == null) {
            return ALIYUN;
        }

        for (PlatformEnum platformEnum : values()) {
            if (platformEnum.getCode().equals(code)) {
                return platformEnum;
            }
        }

        return ALIYUN;
    }

    @Override
    public boolean isType(Integer code) {
        return this.code.equals(code);
    }

    @Override
    public Integer getCode() {
        return code;
    }
}
